import os
import shutil
import fnmatch
import re
from unittest import result

path = './'	#设置创建后文件夹存放的位置
src_path = '../'


for f_name in os.listdir(src_path):
    
    if fnmatch.fnmatch(f_name, '序号*'):
        result1 = os.path.splitext(f_name)
        resutl_ = result1[0].split('_')
        result_num = re.findall("\d+",resutl_[0])[0]
        result_name = resutl_[1]
        # 文件名匹配规则
        
        # print(result_name)
        isExists = os.path.exists(path+'a'+result_num+result_name)
        if not isExists:						#判断如果文件不存在,则创建
            os.makedirs(path+'a'+result_num+result_name)	
            print("%s 目录创建成功"%result_num)
        
        
        shutil.copy(src_path+f_name, path + 'a' + result_num + result_name) 
        
        
        
    

